package com.pat.jrgwt.client;

import com.google.gwt.user.client.ui.CheckBox;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Hyperlink;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.ibm.icu.impl.locale.InternalLocaleBuilder;
import com.sun.jndi.url.corbaname.corbanameURLContextFactory;

public class LoadedDataView extends Composite
{

    protected boolean m_isEuroConversionLoaded = false;
    protected boolean m_isArchivePerformanceLoaded = false;
    protected boolean m_isProfitLossesFxLoaded = false;
    protected boolean m_isProfitLossesFuturesLoaded = false;
    protected boolean m_isDvRatioLoaded = false;
    protected boolean m_isFuturesTradesAmountLoaded = false;
    protected boolean m_isFuturesContractsAmountLoaded = false;
    
    private static class SingletonHolder{
        private static final LoadedDataView instance = new LoadedDataView();
    }
    
    public static LoadedDataView getInstance()
    {
        return SingletonHolder.instance;
    }
    
    protected CheckBox m_euroConversionFlag = new CheckBox("Euro conversion");
    protected CheckBox m_archivePerformanceFlag = new CheckBox("Archive performance");
    protected CheckBox m_profitLossesFxFlag = new CheckBox("Profit/losses (Forex)");
    protected CheckBox m_profitLossesFuturesFlag = new CheckBox("Profit/losses (Futures)");
    protected CheckBox m_dvRatioFlag = new CheckBox("DV ratio");
    protected CheckBox m_futuresTradesAmountFlag = new CheckBox("Trades amount (Futures)");
    protected CheckBox m_futuresContractsAmountFlag = new CheckBox("Contracts amount (Futures)");
    
    private LoadedDataView()
    {
        VerticalPanel panel = new VerticalPanel();
        
        m_euroConversionFlag.setEnabled(false);
        m_archivePerformanceFlag.setEnabled(false);
        m_profitLossesFxFlag.setEnabled(false);
        m_profitLossesFuturesFlag.setEnabled(false);
        m_dvRatioFlag.setEnabled(false);
        m_futuresContractsAmountFlag.setEnabled(false);
        m_futuresTradesAmountFlag.setEnabled(false);
        
        Label lbl = new Label("Loaded data");
        lbl.setStylePrimaryName("cellBold");
        panel.add(lbl);
        
        panel.add(m_euroConversionFlag);
        panel.add(m_archivePerformanceFlag);
        panel.add(m_profitLossesFxFlag);
        panel.add(m_profitLossesFuturesFlag);
        panel.add(m_dvRatioFlag);
        panel.add(m_futuresTradesAmountFlag);
        panel.add(m_futuresContractsAmountFlag);
        
        initWidget(panel);
    }
    
    public synchronized void setIsEuroConversionLoaded(boolean isEuroConversionLoaded)
    {
        m_isEuroConversionLoaded = isEuroConversionLoaded;
        m_euroConversionFlag.setValue(isEuroConversionLoaded);
    }

    public synchronized void setIsArchivePerformanceLoaded(boolean isArchivePerformanceLoaded)
    {
        m_isArchivePerformanceLoaded = isArchivePerformanceLoaded;
        m_archivePerformanceFlag.setValue(isArchivePerformanceLoaded);
    }

    public synchronized void setIsProfitLossesFxLoaded(boolean isProfitLossesLoaded)
    {
        m_isProfitLossesFxLoaded = isProfitLossesLoaded;
        m_profitLossesFxFlag.setValue(isProfitLossesLoaded);
    }

    public synchronized void setIsProfitLossesFuturesLoaded(boolean isProfitLossesLoaded)
    {
        m_isProfitLossesFuturesLoaded = isProfitLossesLoaded;
        m_profitLossesFuturesFlag.setValue(isProfitLossesLoaded);
    }

    public synchronized void setIsDvRatioLoaded(boolean isDvRatioLoaded)
    {
        m_isDvRatioLoaded = isDvRatioLoaded;
        m_dvRatioFlag.setValue(isDvRatioLoaded);
    }

    public synchronized void setIsFuturesTradesAmountLoaded(boolean isLoaded)
    {
        m_isFuturesTradesAmountLoaded = isLoaded;
        m_futuresTradesAmountFlag.setValue(isLoaded);
    }
    
    public synchronized void setIsFuturesContractsAmountLoaded(boolean isLoaded)
    {
        m_isFuturesContractsAmountLoaded = isLoaded;
        m_futuresContractsAmountFlag.setValue(isLoaded);
    }
    
    /**
     * Resets all downloaded flags
     */
    public void resetAll()
    {
        setIsArchivePerformanceLoaded(false);
        setIsEuroConversionLoaded(false);
        setIsProfitLossesFxLoaded(false);
        setIsProfitLossesFuturesLoaded(false);
        setIsDvRatioLoaded(false);
        setIsFuturesContractsAmountLoaded(false);
        setIsFuturesTradesAmountLoaded(false);
    }
    
}
